#include "fxcc/yml/Serializer.h"
#include "fxcc/core/graph/common/AnimationController.h"

using namespace fxcc::yml;
using namespace fxcc::graph::common;

template<>
void Serializer::Encode<StartAnimNode>(YAML::Node& node, const StartAnimNode& inst)
{
	Encode<fxcc::Base>(node, inst);
	SetVariable<int>(node, "m_StartOutPin", inst.m_StartOutPin);

}
template<>
bool Serializer::Decode<StartAnimNode>(const YAML::Node& node, StartAnimNode& inst)
{
	Decode<fxcc::Base>(node, inst);
	GetVariable<int>(node, "m_StartOutPin", inst.m_StartOutPin);
	return true;
}


template<>
 void Serializer::Encode<AnimationController>(YAML::Node& node, const AnimationController& inst)
{
	Encode<fxcc::Base>(node, inst);
	SetVariable<StartAnimNode>(node, "m_StartAnimNode", inst.m_StartAnimNode);
	SetVariable<Params>(node, "m_Params", inst.m_Params);
	SetVariable<int>(node, "m_StartAnimId", inst.m_StartAnimId);
	SetMapVariableInt<AnimationNode>(node, "m_AnimationNodes", inst.m_AnimationNodes, 
		[](const AnimationNode& e) {return e.m_Exist; });
	SetMapVariableInt<AnimTransition>(node, "m_AnimTransitions", inst.m_AnimTransitions,
		[](const AnimTransition& e) {return e.m_Exist; });

}


template<>
bool Serializer::Decode<AnimationController>(const YAML::Node& node, AnimationController& inst)
{
	Decode<fxcc::Base>(node, inst);
	GetVariable<StartAnimNode>(node, "m_StartAnimNode", inst.m_StartAnimNode);
	GetVariable<Params>(node, "m_Params", inst.m_Params);
	GetVariable<int>(node, "m_StartAnimId", inst.m_StartAnimId);
	GetMapVariableInt<AnimationNode>(node, "m_AnimationNodes", inst.m_AnimationNodes);
	GetMapVariableInt<AnimTransition>(node, "m_AnimTransitions", inst.m_AnimTransitions);
	return true;
}
